Skip to main content

All Questions

4votes
2answers
513views

Leetcode: Steps to Make Array Non-decreasing

I was trying out leetcode's Steps to Make Array Non-decreasing As per the challenge's description: You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i ...
ccot's user avatar
  • 361
9votes
4answers
2kviews

Leetcode : First Missing Positive

I was trying out leetcode's first missing positive. As per the challenge's description: Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an ...
ccot's user avatar
  • 361
6votes
1answer
129views

One or more planets to line up with the earth a certain amount of times

I have attempted the below question, however my solution is too slow (i.e. It does not fit the 2 second time constrain for java). How can the solution be optimised? While at IOI 2020 in Singapore, ...
Zareef Akoodie's user avatar
3votes
1answer
96views

Java i/o speed less than python i/o while printing an array

Motivation: I was solving an array based i/o problem and encountered Time Limit Errors, it was later found that the code for java ran roughly 10x slower than the ...
the_illuminated2003's user avatar
2votes
2answers
613views

CSES - Number Spiral - Java TLE

My java code for CSES Introductory problem Number Spiral gives TLE for large inputs, like Input : 100000 170550340 943050741 121998376 943430501 689913499 770079066 586095107 933655238 … (First line/...
Deepti Shahi's user avatar
3votes
1answer
321views

Prime factorisation in java

I came across this question in a coding contest (Java-restricted) and I got TLE. I am unable to provide the link of the question as the contest is closed now. Can I know how can I optimise this? Four ...
PRANATHI G's user avatar
3votes
0answers
198views

Count unique subsequences

I came across this question in a coding competition (Java-restricted) and I got a time-length-exceeded. I am unable to provide a link as the contest is closed now. Can I know how can I optimise this? ...
PRANATHI G's user avatar
-4votes
1answer
86views

Time limit exceeds in this simple program [closed]

Link to problem: https://www.codechef.com/JUNE20B/problems/EVENM Iam trying to solve a simple problem challenge, but getting TLE. I had a different approach earlier, so tried this, again with no ...
drac_o's user avatar
4votes
3answers
404views

How can I optimize my code that uses nested for loops?

I am working to solve a problem where I need to determine if a Point lies on a line connecting two other Points. For example, ...
mlb's user avatar
  • 43
4votes
0answers
79views

Extracting cycles from directed graph with max degree 1 and then performing set cover on cycles

I'm trying to solve P1243E in an efficient manner. The problem in simple words is: Given \$k\$ boxes, \$i\$-th box with \$n_i\$ numbers. All numbers are distinct. We need to select one number from ...
RE60K's user avatar
  • 1,466
4votes
1answer
139views

INCARDS SPOJ challenge

Question- In short question says that you have N bus stops and K bus routes. Every bus routes is linked to two bus stops. Each route has some cost of travelling. It says one person visit any ...
Ladoo's user avatar
8votes
4answers
7kviews

Finding the maximum element of a Stack

I have been solving this problem of Hackerrank recently .. https://www.hackerrank.com/challenges/maximum-element A little bit about the problem You have an empty sequence, and you will be given N ...
Tilak Madichetti's user avatar
5votes
1answer
223views

How to lose plants and aggravate people

Courtesy of a few posts around here I've discovered HackerRank. Poisonous Plants is one of their challenges. Of course, skip the following if you'd like to try it yourself. Challenge: There are \$...
Legato's user avatar
  • 9,839
2votes
1answer
114views

Performance of the String searching algorithm

I am trying to solve a string matching question mentioned here. I recently learned the Knuth–Morris–Pratt algorithm and tried to implement it to solve this question. But I am getting a TLE for this ...
Alpa8's user avatar
8votes
1answer
4kviews

Calculate the running median

I'm trying to solve a challenge where you need to calculate the median every time you add a number. say you have a list of numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ...
Nilzone-'s user avatar

153050per page
close